package com.sws.web.controller.ry_rongyue.push;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sws.common.annotation.Log;
import com.sws.common.core.controller.BaseController;
import com.sws.common.core.domain.AjaxResult;
import com.sws.common.enums.BusinessType;
import com.sws.push.domain.RyService;
import com.sws.push.service.IRyServiceService;
import com.sws.common.utils.poi.ExcelUtil;
import com.sws.common.core.page.TableDataInfo;

/**
 * 服务项目Controller
 * 
 * @author cx
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/ry/service/service")
public class RyServiceController extends BaseController
{
    @Autowired
    private IRyServiceService ryServiceService;

    /**
     * 查询服务项目列表
     */
    @PreAuthorize("@ss.hasPermi('ry/service:service:list')")
    @GetMapping("/list")
    public TableDataInfo list(RyService ryService)
    {
        startPage();
        List<RyService> list = ryServiceService.selectRyServiceList(ryService);
        return getDataTable(list);
    }

    /**
     * 导出服务项目列表
     */
    @PreAuthorize("@ss.hasPermi('ry/service:service:export')")
    @Log(title = "服务项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RyService ryService)
    {
        List<RyService> list = ryServiceService.selectRyServiceList(ryService);
        ExcelUtil<RyService> util = new ExcelUtil<RyService>(RyService.class);
        util.exportExcel(response, list, "服务项目数据");
    }

    /**
     * 获取服务项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('ry/service:service:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ryServiceService.selectRyServiceById(id));
    }

    /**
     * 新增服务项目
     */
    @PreAuthorize("@ss.hasPermi('ry/service:service:add')")
    @Log(title = "服务项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RyService ryService)
    {
        return toAjax(ryServiceService.insertRyService(ryService));
    }

    /**
     * 修改服务项目
     */
    @PreAuthorize("@ss.hasPermi('ry/service:service:edit')")
    @Log(title = "服务项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RyService ryService)
    {
        return toAjax(ryServiceService.updateRyService(ryService));
    }

    /**
     * 删除服务项目
     */
    @PreAuthorize("@ss.hasPermi('ry/service:service:remove')")
    @Log(title = "服务项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ryServiceService.deleteRyServiceByIds(ids));
    }
}
